﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Dcms.BLL;
using Dcms.Model;
using Dcms.Common;

public partial class jobapplycontrol : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int Id = DcmsRequest.GetQueryInt("Id", 0);
            Dcms_PositionBLL pBll = new Dcms_PositionBLL();
            Dcms_PositionModel pModle = new Dcms_PositionModel();
            pModle = pBll.GetModelByID(Id);
            Lit_Num.Text = pModle.Position_Num.ToString();
            Lit_place.Text = pModle.Position_Area;
            Lit_Position.Text = pModle.Position_Name;
            hid_pID.Value = Id.ToString();
            txbBirth.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Dcms_JobSeekerBLL jBll = new Dcms_JobSeekerBLL();
        Dcms_JobSeekerModel jModle = new Dcms_JobSeekerModel();

        jModle.Js_AboutEdu = txbAboutEdu.Text;
        jModle.Js_AboutFamily = txbAboutFamily.Text;
        jModle.Js_AboutTrain = txbAboutTrain.Text;
        jModle.Js_AboutWork = txbAboutWork.Text;
        jModle.Js_Address = txbAddress.Text;
        jModle.Js_AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
        jModle.Js_Birth = Convert.ToDateTime(txbBirth.Text);
        jModle.Js_Computer = txbComputer.Text;
        jModle.Js_Email = txbEmail.Text;
        jModle.Js_FamilyTel = txbFamilyTel.Text;
        jModle.Js_FirstContacter = txbFirstContacter.Text;
        jModle.Js_FirstContacterTel = txbFirstContacterTel.Text;
        jModle.Js_ForeignLanguage = txbForeignLanguage.Text;
        jModle.Js_Identity = txbIdentity.Text;
        jModle.Js_Marry = Utils.StrToInt(rabMarry.SelectedValue, 0);
        jModle.Js_National = txbNational.Text;
        jModle.Js_PayDemands = txbPayDemands.Text;
        jModle.Js_RealName = txbRealName.Text;
        jModle.Js_Sex = Utils.StrToInt(rabSex.SelectedValue, 0);
        jModle.Js_Tel = txbTel.Text;
        jModle.Js_WorkPlace = txbWorkPlace.Text;
        jModle.Js_WorkTime = txbWorkTime.Text;
        jModle.Js_HighEdu = ddlHighEdu.SelectedValue.ToString();

        jBll.AddModel(jModle);

        Dcms_CandidateRecordBLL cBll = new Dcms_CandidateRecordBLL();
        Dcms_CandidateRecordModel cModle = new Dcms_CandidateRecordModel();

        int Js_Id = Utils.StrToInt(jBll.GetDataCount("Select top 1 Js_Id From Dcms_JobSeeker Order By Js_Id Desc"), 0);
        int pID = Utils.StrToInt(hid_pID.Value, 0);

        cModle.Cr_AddTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
        cModle.Cr_jId = Js_Id;
        cModle.Cr_pId = pID;
        cModle.Cr_State = "0";

        cBll.AddModel(cModle);
        Jscript.AlertAndRedirect("申请已经提交,谢谢!","/");
    }
}
